// 同步数据
library SyncData initializer init requires UIInit, MonsterVo, SkillVo

    function myRegisterSyncDataAction takes nothing returns nothing
        local integer uid = GetPlayerId(DzGetTriggerSyncPlayer())
        local string data = DzGetTriggerSyncData()
        
        // 前三位Key用来判断是谁进来的
        local string k = STR_sub(data, 1, 3)
        local string data1 = STR_sub(data, 4, STR_find(data, "-", 1, "false") - 1)
        local string data2 = STR_sub(data, STR_find(data, "-", 1, "false") + 1, -1)

        // call BJDebugMsg("SyncData: " + data)
        // call BJDebugMsg("key: " + k + " data1: " + data1 + " data2: " + data2)

        // 点击了准备按钮
        if "aaa" == k then
            call selectSkill(uid, S2I(data1), S2I(data2))
        endif

        set k = null
        set data = null
    endfunction

    // 注册同步触发器
    private function initTalentUISync takes nothing returns nothing
        local trigger destinyTri = CreateTrigger()

        call DzTriggerRegisterSyncData( destinyTri, "UI_Feng_SysnData", false )
        call TriggerAddCondition(destinyTri, Condition(function myRegisterSyncDataAction))

        set destinyTri = null
    endfunction

    private function init takes nothing returns nothing
        call initTalentUISync()
    endfunction
endlibrary
